#include<bits/stdc++.h>
using namespace std;
long long T,n,m,L,V,d[100005],v[100005],a[100005],p[100005],ans1,ans2;
bool vis[100005];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	while (T--){
		cin>>n>>m>>L>>V;
		ans1=0;
		ans2=0;
		memset(vis,0,sizeof (vis));
		for (int i=1;i<=n;i++)
			cin>>d[i]>>v[i]>>a[i];
		for (int i=1;i<=m;i++)
			cin>>p[i];
		
		for (int i=1;i<=n;i++){
			bool flag=0;
			double s,va;
			for (int j=d[i];j<=L&&va>0;j++){
				s=v[i]*(j-d[i]+1)+0.5*a[i]*(j-d[i]+1)*(j-d[i]+1);
				va=sqrt(v[i]*v[i]+2*a[i]*s);
				for (int k=1;k<=m;k++){
					if (p[k]==j){
						if (va>V){
						   flag=1;
						   vis[p[k]]=1;
					   }
					}
				}
			}
			if (flag)
			    ans1++;
		}
	    for (int i=1;i<=L;i++)
	         if (vis[i]==1)
	             ans2++;
		cout<<ans1<<' '<<m-ans2<<endl;
	}
	return 0;
}
